﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace InChatter.Service.WSHost
{
    public partial class InChatterService : ServiceBase
    {
        private ServiceHost _Host;
        public InChatterService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                _Host = new ServiceHost(typeof(Chat));
                _Host.Open();
            }
            catch (Exception ex)
            {
                EventLog log = new EventLog();
                log.Source = "InChatterService";
                log.WriteEntry(ex.Message, EventLogEntryType.Error);
            }
        }

        protected override void OnStop()
        {
            if (_Host.State != CommunicationState.Closed)
            {
                _Host.Close();
            }
        }
    }
}
